package edu.cqie.smartfarm.exception.handler;

import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import edu.cqie.smartfarm.exception.annotation.GlobalException;
import edu.cqie.smartfarm.exception.exception.IGlobalException;
import edu.cqie.smartfarm.result.R;
import edu.cqie.smartfarm.result.ResultCodeEnum;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@GlobalException(throwable = MismatchedInputException.class)
public class MissingServletRequestParameterExceptionHandler implements IGlobalException<R, MismatchedInputException> {

    @Override
    public R exception(MismatchedInputException throwable, HttpServletRequest request, HttpServletResponse response) {
        return R.Failed(ResultCodeEnum.REQUEST_PARAM_ERROR.getCode(), "请求参数为空");
    }
}
